// make pie chart with highcharts
// @target_id: the element's id which will be renderTo option's value
// @title: the title of the chart
// @items: Array of [item_name, share_in_100_percent]
function pie_chart(target_id, title, items) {
    var options = {
        chart: {
            renderTo: target_id
            , defaultSeriesType: 'pie'
        }
        , title: {
            text: title
        }
        , series: [{
            name: ''
            , data: items
        }]
    }

    var chart = new Highcharts.Chart(options)
}

// this draws a double yAxis chart
// one for sale count, the other for sale figure
// assert len(x_axis_labels) == len(sale_count_items) == len(sale_count_figure)
function sale_chart(target_id, title, x_axis_labels, sale_count_items, sale_figure_items) {
    var options = {
        chart: {
            renderTo: target_id
            , zoomType: 'xy'
        }
        , title: {
            text: title
        }
        , xAxis: [{
            categories: x_axis_labels
        }]
        , yAxis: [{
            title: {
                text: 'Sale Count'
            }
        }, {
            title: {
                text: 'Sale Figure'
            }
            , opposite: true
        }]
        , series: [{
            name: 'Sale Count'
            , type: 'column'
            , data: sale_count_items
            , yAxis: 0
        }, {
            name: 'Sale Figure'
            , type: 'spline'
            , data: sale_figure_items
            , yAxis: 1
        }]
    }

    var chart = new Highcharts.Chart(options)
}

// @series: Array of {name: 'name', data: [d,]}
// assert len(labels) == len(series[i])
function column_chart(target_id, title, labels, series) {
    var options = {
        chart: {
            renderTo: target_id
            , type: 'column'
        }
        , title: {
            text: title
        }
        , xAxis: {
            categories: labels
        }
        , yAxis: {
            title: 'Sale Figure'
        }
        , series: series
    }

    var chart = new Highcharts.Chart(options)
}
